#pragma once
#include "KKComm.h"
#include "KKUIBase.h"
#include "KKRenderI.h"

class KKWindow
{
  protected:
    void *m_hwnd{nullptr};
    KKUIBase *m_uiBase{nullptr};
    KKRenderI *m_render{nullptr};

  public:
    KKWindow();
    static KKWindow *CreateWin(int width, int height, const char *title, int flags);

    void SetUITree(KKUIBase *base);
    KKUIBase *GetUITree();
    void SetRender(KKRenderI *render);
    KKRenderI *GetRender();
    bool _MessageTranslate(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
    // comm functions
  public:
    KKRect m_rect{0, 0, 400, 300};
    KKRect m_rect_client{0, 0, 0, 0};
    bool m_is_active{false};
    bool m_is_show{false};
    std::map<int, void*> m_user_data;

    void Move(int x, int y);
    void Resize(int width, int height);
    void SetTitle(const char *title);
    void Show(bool show, bool isMinimezed = false);
    void MoveCenter();
    void SetIcon(const char *path);
    void SetCursor(KK_CURSOR_STYLE cursor);
    void SetFocus();
    void SetTransparent(unsigned char alpha);
    void *GetWinHandle();
};